﻿using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(UnityEditorHandler))]
public class HandlerInspector : Editor
{
    UnityEditorHandler handler;

    private void OnEnable()
    {
        handler = (UnityEditorHandler)target;
    }

    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
    }

    [System.Obsolete]
    private void OnSceneGUI()
    {
        //第一个参数为在场景中显示的位置
        //第二个参数为显示的名字
        
        Handles.Label(handler.transform.position + new UnityEngine.Vector3(0, 1, 0), "handler");


        //第一个参数为该旋转操作柄的初始旋转角度
        //第二个参数为操作柄显示的位置(以物体的旋转位置为基准)
        //第三个参数为设置操作柄的半径
        //用于在场景中显示半径操作柄
        handler.areaRadius = Handles.RadiusHandle(Quaternion.identity, handler.transform.position, handler.areaRadius);

        //handler.size = Handles.ScaleValueHandle(handler.size, handler.transform.position, Quaternion.identity, handler.size,Handles.ArrowCap, 0.5f);


        for (int i = 0; i < handler.nodePoint.Length; i++)
        {
            Handles.Label(handler.trans[i].position + new UnityEngine.Vector3(0, 1, 0), "handler");
            handler.trans[i].position = Handles.PositionHandle(handler.trans[i].position, handler.trans[i].rotation);
            handler.trans[i].rotation = Handles.RotationHandle(handler.trans[i].rotation, handler.trans[i].position);


            //var value = Handles.ScaleValueHandle(handler.size, handler.transform.position, Quaternion.identity, handler.size, Handles.ArrowCap, 0.5f);
            //handler.trans[i].localScale = new Vector3(value, value, value);
        }


    }


}
